<template>
  <div>
    <van-tabbar v-model="active" active-color="#ee0a24">
      <!-- <router-link to="/home" icon="wap-home-o">首页</router-link> -->
      <van-tabbar-item @click="gotolink(0)" icon="wap-home-o">首页</van-tabbar-item>
      <van-tabbar-item @click="gotolink(1)" icon="apps-o">分类</van-tabbar-item>
      <van-tabbar-item icon="chat-o">消息</van-tabbar-item>
      <van-tabbar-item @click="gotolink(2)" icon="cart-o">购物车</van-tabbar-item>
      <van-tabbar-item @click="gotolink(3)" icon="contact">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
   data() {
    return {
      active: 0,
    };
  },
  created () {
    if(window.location.hash.split('/')[1] == 'goodsList'){
      this.active = 1
    }
  },
  methods: {
    gotolink(num) {
      if(num == 0){
          this.$router.push('/')
      }else if(num == 1){
          this.$router.push('/goodsList')
      }else if(num == 2){
          this.$router.push('/cart')
      }else if(num == 3){
          this.$router.push('/my')
      }
    }
  },
};
</script>

<style lang="less" scoped></style>